#!/bin/bash
#
# 把要添加的域名写入文件 new-domain.list 中,
# 一个域名占一行.
#
# 更新的 init-domain.sh  已经包含了 slave的功能，这个脚本就不用了。
# 2015-8-1


Ndomain=new-domain.list
Destdef=/etc/named/all.adding.def

sed -i '/^$/d' $Ndomain

while read field1 _; do
    echo $field1
    if grep -q $field1 /etc/named/all.*def; then
        echo "you already have add this domain !!!"
    else
        echo "Now adding ..."
        cat << HERE-DOCUMENT >> $Destdef
zone "$field1" IN {
type slave;
file "/var/named/slaves/$field1";
masters { 172.20.9.6; };
};
HERE-DOCUMENT
    fi
done < $Ndomain